home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume17 / contest-prog / part01 next >
Encoding:
Internet Message Format  |  1989-02-06  |  41.2 KB

  1. Subject:  v17i084:  ACM-style programmning contest programs, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: jim nelson <nelson@uncecs.edu>
  6. Posting-number: Volume 17, Issue 84
  7. Archive-name: contest-prog/part01
  8.  
  9. This is a set of ACM-style Programming Contest software that I wrote
  10. for our this year's (1988)'s "Local Programming Contest".  We could not
  11. afford to field a team to go to the Regional Contest, so we just
  12. Po'Boy-ed it here at home.
  13.  
  14. This software is provided without any warranty whatsoever.  It's free
  15. and free of copyright.  It's just what I did for our contest.  It'll
  16. certainly require some version of unix, either BSD4.2 or SysV, or
  17. compatible.  I've tested it on our Sequent B8 (BSD4.2, or very close,
  18. NS32032), and on each of our SysV boxes, one running SysV2.1 (3b2/300)
  19. and the other running SysV3.1 (3b2/310?) (don't ask why they're not
  20. both running 3.1, it's a long bloody story...). No Suns available to me
  21. (isn't that incredible?).
  22.  
  23. What we have here is a combination of shell (Bourne) scripts and
  24. C-programs which I found useful in being a "judge" in our local
  25. "Programming Contest".  We discussed trying to field a team to go to
  26. the Regionals, and decided we 1) couldn't afford the gas, and 2)
  27. couldn't win anyway.
  28.  
  29. Anyway, this software is being put on the net (if it gets past the
  30. moderator) just to possibly inspire others to sorta goad their defunct
  31. ACM/CS student groups (ours died with the dues increase) to come back
  32. alive.
  33.  
  34. #! /bin/sh
  35. # This is a shell archive.  Remove anything before this line, then unpack
  36. # it by saving it into a file and typing "sh file".  To overwrite existing
  37. # files, type "sh file -c".  You can also feed this as standard input via
  38. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  39. # will see the following message at the end:
  40. #        "End of archive 1 (of 3)."
  41. # Contents:  MANIFEST README digits.c f judge n prob1.ans prob1.in
  42. #   prob1.txt prob13.ans prob13.in prob14.ans prob14.in prob15.ans
  43. #   prob15.c prob15.in prob16.ans prob16.in prob17.ans prob17.in
  44. #   prob18.ans prob18.in prob2.ans prob2.c prob2.in prob3.ans prob3.c
  45. #   prob3.in prob3.txt prob4.ans prob4.c prob4.in prob5.ans prob5.c
  46. #   prob5.in prob6.ans prob6.c prob6.in rules scoreascorrect
  47. #   scoreasincorre scoreboard seconds.c sf shorten.c shutofflogins
  48. #   syserr.c testem visc
  49. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  50. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  51.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  52. else
  53. echo shar: Extracting \"'MANIFEST'\" \(2408 characters\)
  54. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  55. X   File Name        Archive #    Description
  56. X-----------------------------------------------------------
  57. X MANIFEST                   1    This shipping list
  58. X Makefile                   2    
  59. X README                     1    
  60. X chexec8.c                  2    
  61. X compare.c                  2    
  62. X contestrules               3    
  63. X digits.c                   1    
  64. X f                          1    
  65. X gr                         3    
  66. X judge                      1    
  67. X n                          1    
  68. X passwd                     2    
  69. X prob1.ans                  1    
  70. X prob1.c                    2    
  71. X prob1.in                   1    
  72. X prob1.txt                  1    
  73. X prob13.ans                 1    
  74. X prob13.c                   2    
  75. X prob13.in                  1    
  76. X prob13.txt                 2    
  77. X prob14.ans                 1    
  78. X prob14.c                   2    
  79. X prob14.in                  1    
  80. X prob14.txt                 2    
  81. X prob15.ans                 1    
  82. X prob15.c                   1    
  83. X prob15.in                  1    
  84. X prob15.txt                 2    
  85. X prob16.ans                 1    
  86. X prob16.c                   2    
  87. X prob16.in                  1    
  88. X prob16.txt                 2    
  89. X prob17.ans                 1    
  90. X prob17.c                   2    
  91. X prob17.in                  1    
  92. X prob17.txt                 2    
  93. X prob18.ans                 1    
  94. X prob18.c                   3    
  95. X prob18.in                  1    
  96. X prob18.txt                 3    
  97. X prob2.ans                  1    
  98. X prob2.c                    1    
  99. X prob2.in                   1    
  100. X prob2.txt                  2    
  101. X prob3.ans                  1    
  102. X prob3.c                    1    
  103. X prob3.in                   1    
  104. X prob3.txt                  1    
  105. X prob4.ans                  1    
  106. X prob4.c                    1    
  107. X prob4.in                   1    
  108. X prob4.txt                  2    
  109. X prob5.ans                  1    
  110. X prob5.c                    1    
  111. X prob5.in                   1    
  112. X prob5.txt                  2    
  113. X prob6.ans                  1    
  114. X prob6.c                    1    
  115. X prob6.in                   1    
  116. X prob6.txt                  2    
  117. X rules                      1    
  118. X sb.c                       2    
  119. X score.c                    3    
  120. X scoreascorrect             1    
  121. X scoreasincorre             1    
  122. X scoreboard                 1    
  123. X seconds.c                  1    
  124. X sf                         1    
  125. X shorten.c                  1    
  126. X shutofflogins              1    
  127. X start                      2    
  128. X syserr.c                   1    
  129. X testem                     1    
  130. X visc                       1    
  131. END_OF_FILE
  132. if test 2408 -ne `wc -c <'MANIFEST'`; then
  133.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  134. fi
  135. # end of 'MANIFEST'
  136. fi
  137. if test -f 'README' -a "${1}" != "-c" ; then 
  138.   echo shar: Will not clobber existing file \"'README'\"
  139. else
  140. echo shar: Extracting \"'README'\" \(7871 characters\)
  141. sed "s/^X//" >'README' <<'END_OF_FILE'
  142. X
  143. XThis is a set of ACM-style Programming Contest software that I wrote
  144. Xfor our this year's (1988)'s "Local Programming Contest".  We could not
  145. Xafford to field a team to go to the Regional Contest, so we just
  146. XPo'Boy-ed it here at home.
  147. X
  148. XThis software is provided without any warranty whatsoever.  It's free
  149. Xand free of copyright.  It's just what I did for our contest.  It'll
  150. Xcertainly require some version of unix, either BSD4.2 or SysV, or
  151. Xcompatible.  I've tested it on our Sequent B8 (BSD4.2, or very close,
  152. XNS32032), and on each of our SysV boxes, one running SysV2.1 (3b2/300)
  153. Xand the other running SysV3.1 (3b2/310?) (don't ask why they're not
  154. Xboth running 3.1, it's a long bloody story...). No Suns available to me
  155. X(isn't that incredible?).
  156. X
  157. XWhat we have here is a combination of shell (Bourne) scripts and
  158. XC-programs which I found useful in being a "judge" in our local
  159. X"Programming Contest".  We discussed trying to field a team to go to
  160. Xthe Regionals, and decided we 1) couldn't afford the gas, and 2)
  161. Xcouldn't win anyway.
  162. X
  163. XAnyway, this software is being put on the net (if it gets past the
  164. Xmoderator) just to possibly inspire others to sorta goad their defunct
  165. XACM/CS student groups (ours died with the dues increase) to come back
  166. Xalive.
  167. X
  168. XInstallation:
  169. X
  170. XAdd a user to your system; his name probably should be "judges" (well,
  171. Xof course, cousin, you gotta be root to do this... trust me!).  Make
  172. Xsure his .profile or .login or .whatever sets his umask to 077.  The
  173. Xgroup of user judges should be the same as his uid.  The group of the
  174. Xteams should be their uids also. But, at least on Berkeley, the group
  175. Xof the directories of the teams should be the same as the group of the
  176. Xjudges.  More on this later.
  177. X
  178. XLog in as judges.  (No root privileges needed, nor desired).
  179. X
  180. XCopy all this stuff from wherever you were reading it into the
  181. X"judges" directory (which is where you should be now).
  182. X
  183. XUnshar the Parts.
  184. X
  185. XLook at Makefile, to see if there are any pathname dependencies
  186. XI missed.  On our system, users are in /usr1, /usr2, and /usr3,
  187. Xand I put judges in /usr2.  More traditional systems will
  188. Xhave /u, /v, etc., I guess.
  189. X
  190. XMake a directory called /usr/contest with 0777 permissions; don't
  191. Xworry, we're only putting easily reconstituted stuff there.  The
  192. X"score" program, for example, needs to live in a directory which
  193. Xis in each of the teams' PATHs; it will be setuid judges, so it
  194. Xcan read the scoreboard, which will be in the judges' protected
  195. Xdirectory.
  196. X
  197. XLook at Makefile to see if you can stand P=& (parallel make).
  198. X
  199. XType
  200. X% make all
  201. X
  202. XThis should compile the necessary C-language programs (score, compare,
  203. Xdigits, seconds, and shorten) and place score and seconds into the
  204. Xcontest directory, along with judge, which is a shell script.
  205. X
  206. XMake accounts of the form teamxx, where xx is either a single digit, or
  207. Xis a double digit.  What I mean is: team2, not team02.  Insure that
  208. Xtheir PATH includes /usr/contest.  Insure that they can mail to judges
  209. Xand that judges can mail to each of them.  Insure that they can read
  210. X/tmp. (If I'm not talking to a root-priv person, forget it, and go send
  211. Xall this stuff to your local administrator).  Make their passwords
  212. Xwhatever you want, but something you can tell them in the poop-session
  213. Xbefore the start of the contest.
  214. X
  215. XType
  216. X% make install
  217. X
  218. XIf all goes well, you should be ready to go.  What I did was run
  219. Xshutofflogins a half-hour before the start of the contest.  It
  220. Xmesses with /etc/passwd by only allowing our magic system accounts,
  221. Xselected faculty, and judges, and teamxx to survive, and all others
  222. Xare taken out.  It needs "nawk" to work.  This step is probably
  223. Xnot necessary;  I was just paranoid.  And, of course, needs to be
  224. Xroot to mess with /etc/passwd.
  225. X
  226. XLong before start-time, edit the file "sf" to reflect the names of
  227. Xyour teams.  Four man teams may not fit.  Truncate them accordingly.
  228. X
  229. XAt start time, type
  230. X% start < sf
  231. Xwhich will set up the scoreboard and start- and end-time files.
  232. X
  233. XTeams submit judged runs by
  234. X% judge probX.pas
  235. X
  236. Xfor example.  The digit(s) (represented by X above) in the filename
  237. Xmust reflect the problem number.  Extensions currently supported are
  238. X.c, .f, .p, and .pas .
  239. X
  240. XThe judges' account must be able to read the teams' directories and
  241. Xprograms.  This is why the teams directories should be readable by
  242. Xgroup judges, but not readable by any other group, especially other
  243. Xteams.  Only judges should be in group judges; and only owner and group
  244. Xjudges should be able to read team directories and files.
  245. X
  246. XThe shell-script "gr" is actually the heart of this whole deal.  It
  247. Xattempts to compile and execute the teams' submissions and to grade the
  248. Xoutput either right or wrong.  The program "compare" was written to
  249. Xfill the void caused by diff -b not working the way I wanted when one
  250. Xof the lines did not begin with a blank.  Also, our fortran generates
  251. Xgratuitious output when a 'stop' statement is executed.  I have not
  252. Xfixed this problem.  What we did was tell those teams using fortran to
  253. Xavoid use of the 'stop' statement.  Running off the end of main is much
  254. Xnicer.
  255. X
  256. XThe little C-program chexec8.c simply executes the teams' submitted
  257. Xprograms after compiling them into a small subdirectory.  The "8"
  258. Xrefers to the eighth version of this little thing.  What made this not
  259. Xjust a simple chdir, chroot, and exec program was a rather incredible
  260. Xback-and-forth between me and a couple of my students in an advanced
  261. Xclass:  "I can steal the input, and I can also steal other teams'
  262. Xoutput".  "How?" "A daemon which never exits and looks in the current
  263. Xdirectory for interesting stuff and copies it into its internal guts
  264. X(remember that it belongs to you, "judges"), and when judges sends mail
  265. Xto the other teams that somebody has solved a problem, it waits for
  266. Xanother instance of turkey, and then sends to the correctly named
  267. Xfiles, an output from its own guts, properly named, as if it were the
  268. Xoutput of a correct run of that particular problem.  First iteration
  269. Xsimply did the chroot.  Second piped input from above and output to
  270. Xabove, doing about all it could except protecting against fork().  ...
  271. Xetc.  What we finally decided was: judges should run the team-program,
  272. Xand should INSURE that no process owned by judges should be allowed to
  273. Xlive after the "first-child" of the judging chexec8 program exits.  I
  274. Xcurrently have that simple-mindedly just issuing kill(...,9) calls to
  275. Xthe next 200 processes.  This will not be sufficient on a busy system,
  276. Xbut thats' where I left it for this time around.  The culprit would 
  277. Xseem to be fork().  Really paranoid sysadmins would just remove
  278. Xfork() from the system library, insure that no students who had
  279. Xever in the past been allowed to login on this system had make
  280. Xcopies of fork(), and ... etc.
  281. X
  282. XThis latter iteration on the possibility of stealing the input and or
  283. Xthe output of other teams' runs was what caused this software to be
  284. Xmore than several weeks late, and why other work, such as grading
  285. Xpapers, has gone undone.  Comments are solicited; versions 1 thru 7 of
  286. Xchexec.c are probably floating around somewhere.  Thanks to Steve
  287. XPerry, David McGough, and Chris Spell for playing the Devil's Advocate
  288. Xfor chexec.
  289. X
  290. XThe "solutions" provided are entirely by me; some of the other judges
  291. Xsubmitted much nicer programs, but mine were written in a semi-contest
  292. Xsituation of "quick and dirty", 'cause I had to write all twelve
  293. Xsolutions one Saturday.  Really, folks, this is not my best code ...
  294. XThey are all in C, although I did re-write a few of them in Pascal and
  295. XFortran just for testing, I then threw those versions away. (No bigotry
  296. Xaround here ...).
  297. X
  298. X
  299. XBugs and flames to
  300. Xnelson@ecsvax.uucp
  301. X...mcnc!ecsvax!nelson
  302. X(too bad it's not ...mcnc!ecsvax!uncw!nelson just yet ... we're
  303. Xtrying)
  304. X
  305. XJim Nelson
  306. XMathematical Sciences Dept.
  307. XUniv. of NC at Wilmington
  308. XWilmington, NC 28403
  309. X919-395-3300 direct, or 919-395-3290 dept. office
  310. END_OF_FILE
  311. if test 7871 -ne `wc -c <'README'`; then
  312.     echo shar: \"'README'\" unpacked with wrong size!
  313. fi
  314. # end of 'README'
  315. fi
  316. if test -f 'digits.c' -a "${1}" != "-c" ; then 
  317.   echo shar: Will not clobber existing file \"'digits.c'\"
  318. else
  319. echo shar: Extracting \"'digits.c'\" \(285 characters\)
  320. sed "s/^X//" >'digits.c' <<'END_OF_FILE'
  321. X#include <stdio.h>
  322. Xmain(argc,argv)
  323. Xchar *argv[];
  324. X{
  325. X    int i,k;
  326. X    char *p,*q;
  327. X    if(argc!=2)exit(1);
  328. X    p=argv[1];
  329. X    q=p;
  330. X    p +=strlen(p)-1;
  331. X    while(p>=q && *p!='/')p--;
  332. X    p++;
  333. X    for(;*p;p++)if(*p>='0' && *p<='9')break;
  334. X    if(!*p){putchar('-');return;}
  335. X    while(*p>='0' && *p<='9'){putchar(*p);p++;}
  336. X}
  337. END_OF_FILE
  338. if test 285 -ne `wc -c <'digits.c'`; then
  339.     echo shar: \"'digits.c'\" unpacked with wrong size!
  340. fi
  341. # end of 'digits.c'
  342. fi
  343. if test -f 'f' -a "${1}" != "-c" ; then 
  344.   echo shar: Will not clobber existing file \"'f'\"
  345. else
  346. echo shar: Extracting \"'f'\" \(778 characters\)
  347. sed "s/^X//" >'f' <<'END_OF_FILE'
  348. X$1 == "root" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  349. X$1 == "nelson" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  350. X$1 == "norris" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  351. X$1 == "herbst" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  352. X$1 == "smithh" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  353. X$1 == "whipkey" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  354. X$1 == "daemon" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  355. X$1 == "usrlimit" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  356. X$1 == "judges" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  357. X$1 == "guest" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  358. X$1 == "score" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  359. X$1 ~  "team" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  360. X$1 ~  "uucp" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  361. X$7 ~  "uucp" {print $1":"$2":"$3":"$4":"$5":"$6":"$7}
  362. X
  363. END_OF_FILE
  364. if test 778 -ne `wc -c <'f'`; then
  365.     echo shar: \"'f'\" unpacked with wrong size!
  366. fi
  367. # end of 'f'
  368. fi
  369. if test -f 'judge' -a "${1}" != "-c" ; then 
  370.   echo shar: Will not clobber existing file \"'judge'\"
  371. else
  372. echo shar: Extracting \"'judge'\" \(282 characters\)
  373. sed "s/^X//" >'judge' <<'END_OF_FILE'
  374. X#! /bin/sh
  375. Xj=$HOME/$1
  376. Xchgrp GROUP $j
  377. Xchmod g+r $j
  378. X# "seconds" must be in everybody's path
  379. X#either /usr/uncw or /usr/local or somesuch
  380. Xecho Judge: $j `seconds` \; `date`>>mailmsg$$
  381. Xmail judges <mailmsg$$
  382. X# leave the mail message in contestant's account (for evidence)
  383. X#rm mailmsg$$
  384. X
  385. END_OF_FILE
  386. if test 282 -ne `wc -c <'judge'`; then
  387.     echo shar: \"'judge'\" unpacked with wrong size!
  388. fi
  389. chmod +x 'judge'
  390. # end of 'judge'
  391. fi
  392. if test -f 'n' -a "${1}" != "-c" ; then 
  393.   echo shar: Will not clobber existing file \"'n'\"
  394. else
  395. echo shar: Extracting \"'n'\" \(40 characters\)
  396. sed "s/^X//" >'n' <<'END_OF_FILE'
  397. Xcp /dev/null $1
  398. X# like
  399. X# > file
  400. X# in sh
  401. END_OF_FILE
  402. if test 40 -ne `wc -c <'n'`; then
  403.     echo shar: \"'n'\" unpacked with wrong size!
  404. fi
  405. chmod +x 'n'
  406. # end of 'n'
  407. fi
  408. if test -f 'prob1.ans' -a "${1}" != "-c" ; then 
  409.   echo shar: Will not clobber existing file \"'prob1.ans'\"
  410. else
  411. echo shar: Extracting \"'prob1.ans'\" \(16 characters\)
  412. sed "s/^X//" >'prob1.ans' <<'END_OF_FILE'
  413. X3
  414. X112
  415. X6555
  416. X9743
  417. END_OF_FILE
  418. if test 16 -ne `wc -c <'prob1.ans'`; then
  419.     echo shar: \"'prob1.ans'\" unpacked with wrong size!
  420. fi
  421. # end of 'prob1.ans'
  422. fi
  423. if test -f 'prob1.in' -a "${1}" != "-c" ; then 
  424.   echo shar: Will not clobber existing file \"'prob1.in'\"
  425. else
  426. echo shar: Extracting \"'prob1.in'\" \(74 characters\)
  427. sed "s/^X//" >'prob1.in' <<'END_OF_FILE'
  428. X9743 3
  429. X3 6555
  430. X21 48
  431. X22 112
  432. X3 29
  433. X6555 18
  434. X3 29
  435. X19 9743
  436. X112 49
  437. X6555 12
  438. X-1 -1
  439. END_OF_FILE
  440. if test 74 -ne `wc -c <'prob1.in'`; then
  441.     echo shar: \"'prob1.in'\" unpacked with wrong size!
  442. fi
  443. # end of 'prob1.in'
  444. fi
  445. if test -f 'prob1.txt' -a "${1}" != "-c" ; then 
  446.   echo shar: Will not clobber existing file \"'prob1.txt'\"
  447. else
  448. echo shar: Extracting \"'prob1.txt'\" \(701 characters\)
  449. sed "s/^X//" >'prob1.txt' <<'END_OF_FILE'
  450. XProblem 1: Cast out duplicate integers.
  451. X
  452. XThe input file will contain integers, two per line, with one
  453. Xblank between the two numbers.
  454. X
  455. XThe two numbers are to be treated a belonging to two arrays,
  456. Xsay left and right.  
  457. X
  458. XThe numbers will be greater than or equal to 0, and less than
  459. Xor equal to 32767.  There will be fewer than five hundred pairs
  460. Xof numbers.
  461. X
  462. XThe last record will contain
  463. X-1 -1
  464. X
  465. XPrint, one per line, in ascending order, those numbers which appear 
  466. Xin both the left-array and the right-array.  Print a particular 
  467. Xnumber only once, even though it may appear in an array more than once.
  468. X
  469. XExample:
  470. X
  471. X9743 3
  472. X3 6555
  473. X21 48
  474. X3 29
  475. X19 9743
  476. X-1 -1
  477. X
  478. XFor the example, the correct output will be
  479. X3
  480. X9743
  481. END_OF_FILE
  482. if test 701 -ne `wc -c <'prob1.txt'`; then
  483.     echo shar: \"'prob1.txt'\" unpacked with wrong size!
  484. fi
  485. # end of 'prob1.txt'
  486. fi
  487. if test -f 'prob13.ans' -a "${1}" != "-c" ; then 
  488.   echo shar: Will not clobber existing file \"'prob13.ans'\"
  489. else
  490. echo shar: Extracting \"'prob13.ans'\" \(21 characters\)
  491. sed "s/^X//" >'prob13.ans' <<'END_OF_FILE'
  492. X1100
  493. X0
  494. X-111
  495. X10
  496. X10001
  497. END_OF_FILE
  498. if test 21 -ne `wc -c <'prob13.ans'`; then
  499.     echo shar: \"'prob13.ans'\" unpacked with wrong size!
  500. fi
  501. # end of 'prob13.ans'
  502. fi
  503. if test -f 'prob13.in' -a "${1}" != "-c" ; then 
  504.   echo shar: Will not clobber existing file \"'prob13.in'\"
  505. else
  506. echo shar: Extracting \"'prob13.in'\" \(72 characters\)
  507. sed "s/^X//" >'prob13.in' <<'END_OF_FILE'
  508. X      110+11-1 +   100
  509. X
  510. X1100-   11000  +111-10
  511. X101-11
  512. X    1111 + 11 -    1
  513. END_OF_FILE
  514. if test 72 -ne `wc -c <'prob13.in'`; then
  515.     echo shar: \"'prob13.in'\" unpacked with wrong size!
  516. fi
  517. # end of 'prob13.in'
  518. fi
  519. if test -f 'prob14.ans' -a "${1}" != "-c" ; then 
  520.   echo shar: Will not clobber existing file \"'prob14.ans'\"
  521. else
  522. echo shar: Extracting \"'prob14.ans'\" \(315 characters\)
  523. sed "s/^X//" >'prob14.ans' <<'END_OF_FILE'
  524. X1 20
  525. X1 30
  526. X1 40
  527. X1 50
  528. X1 60
  529. X1 70
  530. X1 80
  531. X1 90
  532. X2 60
  533. X2 80
  534. X2 100
  535. X2 120
  536. X2 140
  537. X2 160
  538. X2 180
  539. X3 120
  540. X3 150
  541. X3 180
  542. X3 210
  543. X3 240
  544. X3 270
  545. X4 200
  546. X4 240
  547. X4 280
  548. X4 320
  549. X4 360
  550. X5 300
  551. X5 350
  552. X5 400
  553. X5 450
  554. X6 420
  555. X6 480
  556. X6 540
  557. X7 560
  558. X7 630
  559. X8 720
  560. X12 504
  561. X12 756
  562. X12 1008
  563. X13 806
  564. X13 1209
  565. X14 1148
  566. X23 1472
  567. X23 2208
  568. X24 1512
  569. X24 2016
  570. X26 2418
  571. X34 2924
  572. X36 3024
  573. X46 4416
  574. END_OF_FILE
  575. if test 315 -ne `wc -c <'prob14.ans'`; then
  576.     echo shar: \"'prob14.ans'\" unpacked with wrong size!
  577. fi
  578. # end of 'prob14.ans'
  579. fi
  580. if test -f 'prob14.in' -a "${1}" != "-c" ; then 
  581.   echo shar: Will not clobber existing file \"'prob14.in'\"
  582. else
  583. echo shar: Extracting \"'prob14.in'\" \(0 characters\)
  584. sed "s/^X//" >'prob14.in' <<'END_OF_FILE'
  585. END_OF_FILE
  586. if test 0 -ne `wc -c <'prob14.in'`; then
  587.     echo shar: \"'prob14.in'\" unpacked with wrong size!
  588. fi
  589. # end of 'prob14.in'
  590. fi
  591. if test -f 'prob15.ans' -a "${1}" != "-c" ; then 
  592.   echo shar: Will not clobber existing file \"'prob15.ans'\"
  593. else
  594. echo shar: Extracting \"'prob15.ans'\" \(160 characters\)
  595. sed "s/^X//" >'prob15.ans' <<'END_OF_FILE'
  596. X5 10 2 8 1 9 4 13 12 3 7 11  6
  597. X14 13 15 2 5 9 3 11 10 1 8 4 7 6  12
  598. X17 1 3 6 10 15 8 2 14 16 7 4 9 11 13 5  12
  599. X1 3 6 10 15 4 13 7 19 18 5 12 9 14 11 8 17 16  2
  600. END_OF_FILE
  601. if test 160 -ne `wc -c <'prob15.ans'`; then
  602.     echo shar: \"'prob15.ans'\" unpacked with wrong size!
  603. fi
  604. # end of 'prob15.ans'
  605. fi
  606. if test -f 'prob15.c' -a "${1}" != "-c" ; then 
  607.   echo shar: Will not clobber existing file \"'prob15.c'\"
  608. else
  609. echo shar: Extracting \"'prob15.c'\" \(334 characters\)
  610. sed "s/^X//" >'prob15.c' <<'END_OF_FILE'
  611. Xmain(){
  612. X    int a[500];
  613. Xint    m,n,i,j,num,pn,M,N;
  614. Xfor(pn=0;pn<4;pn++){
  615. X    scanf("%d%d",&M,&N);
  616. X    n=N;
  617. X    m=M;
  618. X    for(i=1;i<=n+1;i++)a[i]=i;
  619. X
  620. Xloop:
  621. X    if(m>n)m=1;
  622. X    printf("%d ",a[m]);
  623. X    for(j=m;j<=100;j++)a[j]=a[j+1];
  624. X    n--;
  625. X    if(m>n)m=1;
  626. X    if(n==1){printf(" %d\n", a [m]);continue;}
  627. X    for(i=1;i<=M-1;i++){if(m>n)m=1;m++;if(m>n)m=1;}
  628. X    goto loop;
  629. X
  630. X
  631. X
  632. X
  633. X}
  634. X}
  635. END_OF_FILE
  636. if test 334 -ne `wc -c <'prob15.c'`; then
  637.     echo shar: \"'prob15.c'\" unpacked with wrong size!
  638. fi
  639. # end of 'prob15.c'
  640. fi
  641. if test -f 'prob15.in' -a "${1}" != "-c" ; then 
  642.   echo shar: Will not clobber existing file \"'prob15.in'\"
  643. else
  644. echo shar: Extracting \"'prob15.in'\" \(40 characters\)
  645. sed "s/^X//" >'prob15.in' <<'END_OF_FILE'
  646. X   5   13
  647. X  14   15
  648. X  17   17
  649. X  20   19
  650. END_OF_FILE
  651. if test 40 -ne `wc -c <'prob15.in'`; then
  652.     echo shar: \"'prob15.in'\" unpacked with wrong size!
  653. fi
  654. # end of 'prob15.in'
  655. fi
  656. if test -f 'prob16.ans' -a "${1}" != "-c" ; then 
  657.   echo shar: Will not clobber existing file \"'prob16.ans'\"
  658. else
  659. echo shar: Extracting \"'prob16.ans'\" \(128 characters\)
  660. sed "s/^X//" >'prob16.ans' <<'END_OF_FILE'
  661. X 1  2  13  16  19  20  27  29  30 
  662. X 3 
  663. X 4  5  9  11  14  15  21  22  23  24  26  32  33 
  664. X 6  7  25  31 
  665. X 8  10  12  17  18  28 
  666. END_OF_FILE
  667. if test 128 -ne `wc -c <'prob16.ans'`; then
  668.     echo shar: \"'prob16.ans'\" unpacked with wrong size!
  669. fi
  670. # end of 'prob16.ans'
  671. fi
  672. if test -f 'prob16.in' -a "${1}" != "-c" ; then 
  673.   echo shar: Will not clobber existing file \"'prob16.in'\"
  674. else
  675. echo shar: Extracting \"'prob16.in'\" \(319 characters\)
  676. sed "s/^X//" >'prob16.in' <<'END_OF_FILE'
  677. X   28   33
  678. X   22   33
  679. X   13   20
  680. X    9   11
  681. X   16   29
  682. X   25    7
  683. X   24   15
  684. X   11   23
  685. X   18   28
  686. X   27    2
  687. X    6   31
  688. X   32   11
  689. X    1   27
  690. X   10   12
  691. X   26    5
  692. X   19   16
  693. X   33    9
  694. X   12    8
  695. X    4   14
  696. X    7   31
  697. X   28   17
  698. X   21    4
  699. X    9    5
  700. X   30   20
  701. X   15   21
  702. X   13   29
  703. X    8   28
  704. X   27   16
  705. X   23   14
  706. END_OF_FILE
  707. if test 319 -ne `wc -c <'prob16.in'`; then
  708.     echo shar: \"'prob16.in'\" unpacked with wrong size!
  709. fi
  710. # end of 'prob16.in'
  711. fi
  712. if test -f 'prob17.ans' -a "${1}" != "-c" ; then 
  713.   echo shar: Will not clobber existing file \"'prob17.ans'\"
  714. else
  715. echo shar: Extracting \"'prob17.ans'\" \(361 characters\)
  716. sed "s/^X//" >'prob17.ans' <<'END_OF_FILE'
  717. X5 8 is inside triangle 1
  718. X7 5 is outside triangle 1
  719. X7 10 is outside triangle 1
  720. X8 5 is inside triangle 1
  721. X10 4 is inside triangle 1
  722. X10 8 is inside triangle 1
  723. X11 6 is outside triangle 1
  724. X5 2 is outside triangle 2
  725. X5 7 is outside triangle 2
  726. X5 8 is inside triangle 2
  727. X6 6 is inside triangle 2
  728. X6 8 is outside triangle 2
  729. X8 5 is outside triangle 2
  730. X9 2 is inside triangle 2
  731. END_OF_FILE
  732. if test 361 -ne `wc -c <'prob17.ans'`; then
  733.     echo shar: \"'prob17.ans'\" unpacked with wrong size!
  734. fi
  735. # end of 'prob17.ans'
  736. fi
  737. if test -f 'prob17.in' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'prob17.in'\"
  739. else
  740. echo shar: Extracting \"'prob17.in'\" \(180 characters\)
  741. sed "s/^X//" >'prob17.in' <<'END_OF_FILE'
  742. X   3   7
  743. X   9  11
  744. X  12   3
  745. X   5   8
  746. X   7   5
  747. X   7  10
  748. X   8   5
  749. X  10   4
  750. X  10   8
  751. X  11   6
  752. X   4  11
  753. X   6   4
  754. X  10   1
  755. X   5   2
  756. X   5   7
  757. X   5   8
  758. X   6   6
  759. X   6   8
  760. X   8   5
  761. X   9   2
  762. END_OF_FILE
  763. if test 180 -ne `wc -c <'prob17.in'`; then
  764.     echo shar: \"'prob17.in'\" unpacked with wrong size!
  765. fi
  766. # end of 'prob17.in'
  767. fi
  768. if test -f 'prob18.ans' -a "${1}" != "-c" ; then 
  769.   echo shar: Will not clobber existing file \"'prob18.ans'\"
  770. else
  771. echo shar: Extracting \"'prob18.ans'\" \(200 characters\)
  772. sed "s/^X//" >'prob18.ans' <<'END_OF_FILE'
  773. X
  774. Xthequickbrownfoxjumpsoverthelazydog'sbackcqcqdek4xehownowbrowncow
  775. Xkcex4czydoqhworbwkaasovertgcon******woeblpownfoxjuh'qwc**********ondsemrthequickb
  776. X
  777. Ximroft thee **lla  snow i
  778. Xnow is the time for all
  779. END_OF_FILE
  780. if test 200 -ne `wc -c <'prob18.ans'`; then
  781.     echo shar: \"'prob18.ans'\" unpacked with wrong size!
  782. fi
  783. # end of 'prob18.ans'
  784. fi
  785. if test -f 'prob18.in' -a "${1}" != "-c" ; then 
  786.   echo shar: Will not clobber existing file \"'prob18.in'\"
  787. else
  788. echo shar: Extracting \"'prob18.in'\" \(106 characters\)
  789. sed "s/^X//" >'prob18.in' <<'END_OF_FILE'
  790. Xencode
  791. Xthequickbrownfoxjumpsoverthelazydog'sbackcqcqdek4xehownowbrowncow
  792. Xdecode
  793. Ximroft thee **lla  snow i
  794. END_OF_FILE
  795. if test 106 -ne `wc -c <'prob18.in'`; then
  796.     echo shar: \"'prob18.in'\" unpacked with wrong size!
  797. fi
  798. # end of 'prob18.in'
  799. fi
  800. if test -f 'prob2.ans' -a "${1}" != "-c" ; then 
  801.   echo shar: Will not clobber existing file \"'prob2.ans'\"
  802. else
  803. echo shar: Extracting \"'prob2.ans'\" \(220 characters\)
  804. sed "s/^X//" >'prob2.ans' <<'END_OF_FILE'
  805. X    9    1
  806. X   32   12
  807. X   97    5
  808. X   98    1
  809. X   99    1
  810. X  100    3
  811. X  101    9
  812. X  102    2
  813. X  103    1
  814. X  104    5
  815. X  105    4
  816. X  108    2
  817. X  109    4
  818. X  110    1
  819. X  111    7
  820. X  112    2
  821. X  114    4
  822. X  115    2
  823. X  116   10
  824. X  121    3
  825. END_OF_FILE
  826. if test 220 -ne `wc -c <'prob2.ans'`; then
  827.     echo shar: \"'prob2.ans'\" unpacked with wrong size!
  828. fi
  829. # end of 'prob2.ans'
  830. fi
  831. if test -f 'prob2.c' -a "${1}" != "-c" ; then 
  832.   echo shar: Will not clobber existing file \"'prob2.c'\"
  833. else
  834. echo shar: Extracting \"'prob2.c'\" \(308 characters\)
  835. sed "s/^X//" >'prob2.c' <<'END_OF_FILE'
  836. Xmain()
  837. X{
  838. X    char line[99];
  839. X
  840. X    int count[256];
  841. X    int i;
  842. X        char *gets();
  843. X
  844. X    for(i=0;i<256;i++)count[i]=0;
  845. X    while( gets(line)==line )
  846. X        for(i=0;line[i] && line[i]!='\n';i++)
  847. X            count[ line[i] ]++;
  848. X        
  849. X    printf("%5d%5d\n",'\t',count['\t']);
  850. X    for(i=' ';i<0177;i++) if(count[i])printf("%5d%5d\n",i,count[i]);
  851. X    exit(0);
  852. X}
  853. END_OF_FILE
  854. if test 308 -ne `wc -c <'prob2.c'`; then
  855.     echo shar: \"'prob2.c'\" unpacked with wrong size!
  856. fi
  857. # end of 'prob2.c'
  858. fi
  859. if test -f 'prob2.in' -a "${1}" != "-c" ; then 
  860.   echo shar: Will not clobber existing file \"'prob2.in'\"
  861. else
  862. echo shar: Extracting \"'prob2.in'\" \(84 characters\)
  863. sed "s/^X//" >'prob2.in' <<'END_OF_FILE'
  864. Xtime for all
  865. X    good men to
  866. Xcome to the aid of
  867. Xtheie party
  868. Xthirty days hath september
  869. END_OF_FILE
  870. if test 84 -ne `wc -c <'prob2.in'`; then
  871.     echo shar: \"'prob2.in'\" unpacked with wrong size!
  872. fi
  873. # end of 'prob2.in'
  874. fi
  875. if test -f 'prob3.ans' -a "${1}" != "-c" ; then 
  876.   echo shar: Will not clobber existing file \"'prob3.ans'\"
  877. else
  878. echo shar: Extracting \"'prob3.ans'\" \(103 characters\)
  879. sed "s/^X//" >'prob3.ans' <<'END_OF_FILE'
  880. XThe quick brown fox jumps over the lazy dog's back.
  881. XThe quick blue fox jumps over the lazy dog's back.
  882. END_OF_FILE
  883. if test 103 -ne `wc -c <'prob3.ans'`; then
  884.     echo shar: \"'prob3.ans'\" unpacked with wrong size!
  885. fi
  886. # end of 'prob3.ans'
  887. fi
  888. if test -f 'prob3.c' -a "${1}" != "-c" ; then 
  889.   echo shar: Will not clobber existing file \"'prob3.c'\"
  890. else
  891. echo shar: Extracting \"'prob3.c'\" \(188 characters\)
  892. sed "s/^X//" >'prob3.c' <<'END_OF_FILE'
  893. Xmain(){
  894. X    char line[256];
  895. X    int i;
  896. X    char *gets();
  897. X    while(gets(line)==line){
  898. X        i=0;
  899. X        while(line[i]>=' ' || line[i]=='\t')i++;
  900. X        i--;
  901. X        while(i>=0){putchar(line[i--]);}
  902. X        putchar('\n');
  903. X    }
  904. X}
  905. END_OF_FILE
  906. if test 188 -ne `wc -c <'prob3.c'`; then
  907.     echo shar: \"'prob3.c'\" unpacked with wrong size!
  908. fi
  909. # end of 'prob3.c'
  910. fi
  911. if test -f 'prob3.in' -a "${1}" != "-c" ; then 
  912.   echo shar: Will not clobber existing file \"'prob3.in'\"
  913. else
  914. echo shar: Extracting \"'prob3.in'\" \(103 characters\)
  915. sed "s/^X//" >'prob3.in' <<'END_OF_FILE'
  916. X.kcab s'god yzal eht revo spmuj xof nworb kciuq ehT
  917. X.kcab s'god yzal eht revo spmuj xof eulb kciuq ehT
  918. END_OF_FILE
  919. if test 103 -ne `wc -c <'prob3.in'`; then
  920.     echo shar: \"'prob3.in'\" unpacked with wrong size!
  921. fi
  922. # end of 'prob3.in'
  923. fi
  924. if test -f 'prob3.txt' -a "${1}" != "-c" ; then 
  925.   echo shar: Will not clobber existing file \"'prob3.txt'\"
  926. else
  927. echo shar: Extracting \"'prob3.txt'\" \(753 characters\)
  928. sed "s/^X//" >'prob3.txt' <<'END_OF_FILE'
  929. XProblem 3: Reverse the characters in a line.
  930. X
  931. XFor each line in a file (on the standard input), reverse
  932. Xthe order of the characters in the line.
  933. X
  934. XThere is an unknown, but fairly small (less than ten thousand)
  935. Xnumber of lines in the input file.
  936. X
  937. XEach line is guaranteed to be less than 80 characters long.
  938. X
  939. XFor example, if the file on stdin consists of exactly two lines:
  940. X
  941. Xhello
  942. Xworld!
  943. X
  944. Xthen the output should be
  945. X
  946. Xolleh
  947. X!dlrow
  948. X
  949. Xon exactly two lines.  The byte count of a correct output for the
  950. Xexample would be 13 (remember that the newlines count as bytes).
  951. XThe blank lines in the above listing of the explanation are not 
  952. Xpart of the output.  Note that each output line should be left-
  953. Xjustified (e.g., the ! in the example must come out in column 1).
  954. X
  955. END_OF_FILE
  956. if test 753 -ne `wc -c <'prob3.txt'`; then
  957.     echo shar: \"'prob3.txt'\" unpacked with wrong size!
  958. fi
  959. # end of 'prob3.txt'
  960. fi
  961. if test -f 'prob4.ans' -a "${1}" != "-c" ; then 
  962.   echo shar: Will not clobber existing file \"'prob4.ans'\"
  963. else
  964. echo shar: Extracting \"'prob4.ans'\" \(23 characters\)
  965. sed "s/^X//" >'prob4.ans' <<'END_OF_FILE'
  966. X1 2
  967. X3 6
  968. X-1 4
  969. X-1 6
  970. X-1 6
  971. END_OF_FILE
  972. if test 23 -ne `wc -c <'prob4.ans'`; then
  973.     echo shar: \"'prob4.ans'\" unpacked with wrong size!
  974. fi
  975. # end of 'prob4.ans'
  976. fi
  977. if test -f 'prob4.c' -a "${1}" != "-c" ; then 
  978.   echo shar: Will not clobber existing file \"'prob4.c'\"
  979. else
  980. echo shar: Extracting \"'prob4.c'\" \(768 characters\)
  981. sed "s/^X//" >'prob4.c' <<'END_OF_FILE'
  982. Xmain(){
  983. X/*    integer odds(100),evens(100)*/
  984. X    int odds[101],evens[101];
  985. X    int k; /*had to be added... fortran implicitly declared it*/
  986. X/*    integer a*/
  987. X    int a;
  988. X/*    integer i,j*/
  989. X    int i,j;
  990. X
  991. X/*    i=1*/
  992. X/*    j=1*/
  993. X    i=j=1;
  994. X/*    do 10 k=1,100*/
  995. X    for(k=1;k<=100;k++)odds[k]=evens[k]= -1;
  996. X/*    odds(k)= -1*/
  997. X/*10    evens(k)= -1*/
  998. X
  999. X/*1    read*,a*/
  1000. Xloop: scanf("%d",&a);
  1001. X/*    if(a.lt.0)goto 4*/
  1002. X    if(a<0)goto out;
  1003. X/*    if( mod(a,2) .eq. 0)goto 2*/
  1004. X/*    odds(i)=a*/
  1005. X/*    i= i+1*/
  1006. X/*    goto 3*/
  1007. X/*2    evens(j)=a*/
  1008. X/*    j=j+1*/
  1009. X/*3    continue*/
  1010. X    if(a%2)odds[i++]=a;
  1011. X    else evens[ j++]=a;
  1012. X/*    goto 1*/
  1013. X    goto loop;
  1014. X
  1015. X/*4    continue*/
  1016. Xout:
  1017. X/*    j = max(i,j) -1*/
  1018. X    j= (j>i?j:i)-1;
  1019. X    for(i=1;i<=j;i++)
  1020. X/*    do 5 i=1,j*/
  1021. X/*    print*,odds(i),evens(i)*/
  1022. X    printf("%d %d\n",odds[i],evens[i]);
  1023. X/*5    continue*/
  1024. X/*    stop*/
  1025. X/*    end*/
  1026. Xexit(0);
  1027. X}
  1028. END_OF_FILE
  1029. if test 768 -ne `wc -c <'prob4.c'`; then
  1030.     echo shar: \"'prob4.c'\" unpacked with wrong size!
  1031. fi
  1032. # end of 'prob4.c'
  1033. fi
  1034. if test -f 'prob4.in' -a "${1}" != "-c" ; then 
  1035.   echo shar: Will not clobber existing file \"'prob4.in'\"
  1036. else
  1037. echo shar: Extracting \"'prob4.in'\" \(25 characters\)
  1038. sed "s/^X//" >'prob4.in' <<'END_OF_FILE'
  1039. X 1
  1040. X       3
  1041. X2
  1042. X6
  1043. X4
  1044. X6
  1045. X6
  1046. X-1
  1047. END_OF_FILE
  1048. if test 25 -ne `wc -c <'prob4.in'`; then
  1049.     echo shar: \"'prob4.in'\" unpacked with wrong size!
  1050. fi
  1051. # end of 'prob4.in'
  1052. fi
  1053. if test -f 'prob5.ans' -a "${1}" != "-c" ; then 
  1054.   echo shar: Will not clobber existing file \"'prob5.ans'\"
  1055. else
  1056. echo shar: Extracting \"'prob5.ans'\" \(16 characters\)
  1057. sed "s/^X//" >'prob5.ans' <<'END_OF_FILE'
  1058. X4
  1059. X3
  1060. X1
  1061. X0
  1062. X6
  1063. X4
  1064. X2
  1065. X3
  1066. END_OF_FILE
  1067. if test 16 -ne `wc -c <'prob5.ans'`; then
  1068.     echo shar: \"'prob5.ans'\" unpacked with wrong size!
  1069. fi
  1070. # end of 'prob5.ans'
  1071. fi
  1072. if test -f 'prob5.c' -a "${1}" != "-c" ; then 
  1073.   echo shar: Will not clobber existing file \"'prob5.c'\"
  1074. else
  1075. echo shar: Extracting \"'prob5.c'\" \(284 characters\)
  1076. sed "s/^X//" >'prob5.c' <<'END_OF_FILE'
  1077. Xmain()
  1078. X{
  1079. X    char line[256];
  1080. X    int i,j,wc;
  1081. X    char *gets();
  1082. X    
  1083. X    while( gets(line)==line)
  1084. X    {
  1085. X        if(strlen(line)==0){printf("0\n");continue;}
  1086. X        i=0;
  1087. X        wc=0;
  1088. X    for(i=0;line[i];i++){
  1089. X    if(line[i]>='a' && line[i]<='z'){
  1090. X                        if(line[i+1]<'a' ||line[i+1]>'z')wc++;
  1091. X            }
  1092. X    }
  1093. X    printf("%d\n",wc);
  1094. X    }
  1095. X}
  1096. X
  1097. END_OF_FILE
  1098. if test 284 -ne `wc -c <'prob5.c'`; then
  1099.     echo shar: \"'prob5.c'\" unpacked with wrong size!
  1100. fi
  1101. # end of 'prob5.c'
  1102. fi
  1103. if test -f 'prob5.in' -a "${1}" != "-c" ; then 
  1104.   echo shar: Will not clobber existing file \"'prob5.in'\"
  1105. else
  1106. echo shar: Extracting \"'prob5.in'\" \(136 characters\)
  1107. sed "s/^X//" >'prob5.in' <<'END_OF_FILE'
  1108. Xnow is the time
  1109. X thirty days hath
  1110. X   september
  1111. X
  1112. X   testing testing cqcqcq de k4xe
  1113. X   how now brown cow
  1114. X   more words
  1115. X   some more words
  1116. END_OF_FILE
  1117. if test 136 -ne `wc -c <'prob5.in'`; then
  1118.     echo shar: \"'prob5.in'\" unpacked with wrong size!
  1119. fi
  1120. # end of 'prob5.in'
  1121. fi
  1122. if test -f 'prob6.ans' -a "${1}" != "-c" ; then 
  1123.   echo shar: Will not clobber existing file \"'prob6.ans'\"
  1124. else
  1125. echo shar: Extracting \"'prob6.ans'\" \(116 characters\)
  1126. sed "s/^X//" >'prob6.ans' <<'END_OF_FILE'
  1127. X1 2 3 4 6 0
  1128. X4 3 2 1 0 6
  1129. X1 3 2 4 5 1
  1130. X1 2 4 3 5 1
  1131. X3 4 1 2 2 4
  1132. X3 4 2 1 1 5
  1133. X2733 13274 11 1 1 5
  1134. X4 3 2 5 3 3
  1135. X6 4 3 5 2 4
  1136. END_OF_FILE
  1137. if test 116 -ne `wc -c <'prob6.ans'`; then
  1138.     echo shar: \"'prob6.ans'\" unpacked with wrong size!
  1139. fi
  1140. # end of 'prob6.ans'
  1141. fi
  1142. if test -f 'prob6.c' -a "${1}" != "-c" ; then 
  1143.   echo shar: Will not clobber existing file \"'prob6.c'\"
  1144. else
  1145. echo shar: Extracting \"'prob6.c'\" \(266 characters\)
  1146. sed "s/^X//" >'prob6.c' <<'END_OF_FILE'
  1147. Xmain(){
  1148. X    int i,j;
  1149. X    int lt,gt,a[4];
  1150. X    while( scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])==4){
  1151. X    if(a[0]<0)exit(0);
  1152. X    gt=lt=0;
  1153. X    for(i=0;i<=2;i++)for(j=i+1;j<=3;j++){
  1154. X    if(a[i]<a[j])lt++;
  1155. X    if(a[i]>a[j])gt++;
  1156. X    }
  1157. X    printf("%d %d %d %d %d %d\n",a[0],a[1],a[2],a[3],lt,gt);
  1158. X    }
  1159. X    }
  1160. END_OF_FILE
  1161. if test 266 -ne `wc -c <'prob6.c'`; then
  1162.     echo shar: \"'prob6.c'\" unpacked with wrong size!
  1163. fi
  1164. # end of 'prob6.c'
  1165. fi
  1166. if test -f 'prob6.in' -a "${1}" != "-c" ; then 
  1167.   echo shar: Will not clobber existing file \"'prob6.in'\"
  1168. else
  1169. echo shar: Extracting \"'prob6.in'\" \(92 characters\)
  1170. sed "s/^X//" >'prob6.in' <<'END_OF_FILE'
  1171. X1 2 3 4
  1172. X4 3 2 1
  1173. X1 3 2 4
  1174. X1 2 4 3
  1175. X3 4 1 2
  1176. X3 4 2 1
  1177. X2733 13274 11 1
  1178. X4 3 2 5
  1179. X6 4 3 5
  1180. X-1 -1 -1 -1
  1181. END_OF_FILE
  1182. if test 92 -ne `wc -c <'prob6.in'`; then
  1183.     echo shar: \"'prob6.in'\" unpacked with wrong size!
  1184. fi
  1185. # end of 'prob6.in'
  1186. fi
  1187. if test -f 'rules' -a "${1}" != "-c" ; then 
  1188.   echo shar: Will not clobber existing file \"'rules'\"
  1189. else
  1190. echo shar: Extracting \"'rules'\" \(44 characters\)
  1191. sed "s/^X//" >'rules' <<'END_OF_FILE'
  1192. X/usr/local/bin/less /usr/news/contestrules
  1193. X
  1194. END_OF_FILE
  1195. if test 44 -ne `wc -c <'rules'`; then
  1196.     echo shar: \"'rules'\" unpacked with wrong size!
  1197. fi
  1198. chmod +x 'rules'
  1199. # end of 'rules'
  1200. fi
  1201. if test -f 'scoreascorrect' -a "${1}" != "-c" ; then 
  1202.   echo shar: Will not clobber existing file \"'scoreascorrect'\"
  1203. else
  1204. echo shar: Extracting \"'scoreascorrect'\" \(653 characters\)
  1205. sed "s/^X//" >'scoreascorrect' <<'END_OF_FILE'
  1206. Xif test -f lock
  1207. Xthen
  1208. Xecho busy
  1209. Xexit
  1210. Xelse
  1211. Xtouch lock
  1212. Xfi
  1213. Xecho "team no. ?"
  1214. Xread t
  1215. Xecho "problem no. ?"
  1216. Xread q
  1217. Xmv t${t}p${q}* keep
  1218. Xt=team$t
  1219. X#    echo "1" $qq $q $seconds>>scoreboard
  1220. X# do this manually
  1221. X
  1222. X    echo yes their output is correct
  1223. X    echo you must manually edit the scoreboard and change the
  1224. X    echo desired \"0\" in col 1 to a \"1\"
  1225. X    echo \
  1226. X    "CONGRATS! $t successfully did prob$q at `date`">\
  1227. X        $src.done
  1228. X    mail $t < $src.done
  1229. X    echo "submitted: $seconds">$src.at
  1230. X    echo "$t completed problem $q at `date`">$src.msg
  1231. X    list=""
  1232. X    for i in `cat listofteams` ; do
  1233. X        case $i in
  1234. X            $t) ;;
  1235. X            *) list="$list $i"
  1236. X            ;;
  1237. X        esac
  1238. X    done
  1239. X    mail $list < $src.msg
  1240. X    rm lock
  1241. X    exit
  1242. END_OF_FILE
  1243. if test 653 -ne `wc -c <'scoreascorrect'`; then
  1244.     echo shar: \"'scoreascorrect'\" unpacked with wrong size!
  1245. fi
  1246. chmod +x 'scoreascorrect'
  1247. # end of 'scoreascorrect'
  1248. fi
  1249. if test -f 'scoreasincorre' -a "${1}" != "-c" ; then 
  1250.   echo shar: Will not clobber existing file \"'scoreasincorre'\"
  1251. else
  1252. echo shar: Extracting \"'scoreasincorre'\" \(470 characters\)
  1253. sed "s/^X//" >'scoreasincorre' <<'END_OF_FILE'
  1254. X    echo "team no. ?"
  1255. X    read qq
  1256. X    t=team$qq
  1257. X    echo "problem no. ?"
  1258. X    read q
  1259. X    p=prob$q
  1260. X    seconds=`seconds`
  1261. X    echo "0" $qq $q $seconds >>scoreboard
  1262. X
  1263. X    echo not correct
  1264. X    echo if necessary, you must manually change the appropriate
  1265. X    echo \"0\" in scoreboard
  1266. X    echo  "do you wish to mail them an explanatory note? "
  1267. X    read zork
  1268. X    case $zork in
  1269. X        y) 
  1270. X        echo "mail $t"
  1271. X        mail -s "$p" $t
  1272. X        ;;
  1273. X        *) echo "your $p not correct">failure$$
  1274. X        mail -s "$p" $t<failure$$
  1275. X        rm -f failure$$
  1276. X        ;;
  1277. X    esac
  1278. END_OF_FILE
  1279. if test 470 -ne `wc -c <'scoreasincorre'`; then
  1280.     echo shar: \"'scoreasincorre'\" unpacked with wrong size!
  1281. fi
  1282. chmod +x 'scoreasincorre'
  1283. # end of 'scoreasincorre'
  1284. fi
  1285. if test -f 'scoreboard' -a "${1}" != "-c" ; then 
  1286.   echo shar: Will not clobber existing file \"'scoreboard'\"
  1287. else
  1288. echo shar: Extracting \"'scoreboard'\" \(246 characters\)
  1289. sed "s/^X//" >'scoreboard' <<'END_OF_FILE'
  1290. X21
  1291. X1 3 prentice,hall
  1292. X2 3 addison,wesley
  1293. X3 3 bob,carol,ted,alice
  1294. X4 3 von,neumann
  1295. X5 2 eckert,mauchly
  1296. X6 2 boole,babbage
  1297. X7 1 romeo,juliet
  1298. X8 1 laurel,hardy
  1299. X9 1 a_g_bell,watson
  1300. X10 1 abbott,costello
  1301. X11 1 hansel,gretel
  1302. X12 1 the_judges
  1303. X-1 -1 xx
  1304. X596574216
  1305. END_OF_FILE
  1306. if test 246 -ne `wc -c <'scoreboard'`; then
  1307.     echo shar: \"'scoreboard'\" unpacked with wrong size!
  1308. fi
  1309. # end of 'scoreboard'
  1310. fi
  1311. if test -f 'seconds.c' -a "${1}" != "-c" ; then 
  1312.   echo shar: Will not clobber existing file \"'seconds.c'\"
  1313. else
  1314. echo shar: Extracting \"'seconds.c'\" \(65 characters\)
  1315. sed "s/^X//" >'seconds.c' <<'END_OF_FILE'
  1316. Xmain(){
  1317. X    long time(), t;
  1318. X    printf("%ld\n",time( (long *) 0 ));
  1319. X    }
  1320. END_OF_FILE
  1321. if test 65 -ne `wc -c <'seconds.c'`; then
  1322.     echo shar: \"'seconds.c'\" unpacked with wrong size!
  1323. fi
  1324. # end of 'seconds.c'
  1325. fi
  1326. if test -f 'sf' -a "${1}" != "-c" ; then 
  1327.   echo shar: Will not clobber existing file \"'sf'\"
  1328. else
  1329. echo shar: Extracting \"'sf'\" \(227 characters\)
  1330. sed "s/^X//" >'sf' <<'END_OF_FILE'
  1331. X1
  1332. X3
  1333. Xprentice,hall
  1334. X2
  1335. X3
  1336. Xaddison,wesley
  1337. X3
  1338. X3
  1339. Xbob,carol,ted,alice
  1340. X4
  1341. X3
  1342. Xvon,neumann
  1343. X5
  1344. X2
  1345. Xeckert,mauchly
  1346. X6
  1347. X2
  1348. Xboole,babbage
  1349. X7
  1350. X1
  1351. Xromeo,juliet
  1352. X8
  1353. X1
  1354. Xlaurel,hardy
  1355. X9
  1356. X1
  1357. Xa_g_bell,watson
  1358. X10
  1359. X1
  1360. Xabbott,costello
  1361. X11
  1362. X1
  1363. Xhansel,gretel
  1364. X12
  1365. X1
  1366. Xthe_judges
  1367. X-1
  1368. END_OF_FILE
  1369. if test 227 -ne `wc -c <'sf'`; then
  1370.     echo shar: \"'sf'\" unpacked with wrong size!
  1371. fi
  1372. # end of 'sf'
  1373. fi
  1374. if test -f 'shorten.c' -a "${1}" != "-c" ; then 
  1375.   echo shar: Will not clobber existing file \"'shorten.c'\"
  1376. else
  1377. echo shar: Extracting \"'shorten.c'\" \(359 characters\)
  1378. sed "s/^X//" >'shorten.c' <<'END_OF_FILE'
  1379. X#include <stdio.h>
  1380. X#define zero '0'
  1381. X#define nine '9'
  1382. Xmain(argc,argv)
  1383. Xchar *argv[];
  1384. X{
  1385. X    int i,k;
  1386. X    char *p,*q;
  1387. X    if(argc!=2)exit(1);
  1388. X    p=argv[1];
  1389. X    putchar('t');
  1390. X    while( *p &&(*p<zero || *p>nine))p++;
  1391. X    while(*p &&(*p>=zero && *p<=nine)){putchar(*p);p++;}
  1392. X    putchar('p');
  1393. X    while( *p &&(*p<zero || *p>nine))p++;
  1394. X    while(*p &&(*p>=zero && *p<=nine)){putchar(*p);p++;}
  1395. X}
  1396. END_OF_FILE
  1397. if test 359 -ne `wc -c <'shorten.c'`; then
  1398.     echo shar: \"'shorten.c'\" unpacked with wrong size!
  1399. fi
  1400. # end of 'shorten.c'
  1401. fi
  1402. if test -f 'shutofflogins' -a "${1}" != "-c" ; then 
  1403.   echo shar: Will not clobber existing file \"'shutofflogins'\"
  1404. else
  1405. echo shar: Extracting \"'shutofflogins'\" \(212 characters\)
  1406. sed "s/^X//" >'shutofflogins' <<'END_OF_FILE'
  1407. X#! /bin/sh
  1408. X/usr/uncw/nawk -F: -f f /etc/passwd >passwd
  1409. X/bin/cp /etc/passwd /etc/passwd.precon
  1410. X/bin/cp passwd /etc/passwd
  1411. Xfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14
  1412. Xdo
  1413. X/bin/cp /dev/null /usr/spool/mail/team$i
  1414. Xdone
  1415. END_OF_FILE
  1416. if test 212 -ne `wc -c <'shutofflogins'`; then
  1417.     echo shar: \"'shutofflogins'\" unpacked with wrong size!
  1418. fi
  1419. chmod +x 'shutofflogins'
  1420. # end of 'shutofflogins'
  1421. fi
  1422. if test -f 'syserr.c' -a "${1}" != "-c" ; then 
  1423.   echo shar: Will not clobber existing file \"'syserr.c'\"
  1424. else
  1425. echo shar: Extracting \"'syserr.c'\" \(294 characters\)
  1426. sed "s/^X//" >'syserr.c' <<'END_OF_FILE'
  1427. X#ifndef stderr
  1428. X#include <stdio.h>
  1429. X#endif
  1430. X
  1431. Xvoid syserr(msg)
  1432. Xchar *msg;
  1433. X{
  1434. X    extern int errno, sys_nerr;
  1435. X    extern char *sys_errlist[];
  1436. X    fprintf(stderr,"ERROR: %s (%d",msg,errno);
  1437. X    if(errno>0&&errno<sys_nerr)
  1438. X        fprintf(stderr,"; %s)\n",sys_errlist[errno]);
  1439. X    else
  1440. X        fprintf(stderr,")\n");
  1441. X    exit(1);
  1442. X}
  1443. END_OF_FILE
  1444. if test 294 -ne `wc -c <'syserr.c'`; then
  1445.     echo shar: \"'syserr.c'\" unpacked with wrong size!
  1446. fi
  1447. # end of 'syserr.c'
  1448. fi
  1449. if test -f 'testem' -a "${1}" != "-c" ; then 
  1450.   echo shar: Will not clobber existing file \"'testem'\"
  1451. else
  1452. echo shar: Extracting \"'testem'\" \(487 characters\)
  1453. sed "s/^X//" >'testem' <<'END_OF_FILE'
  1454. X#! /bin/sh
  1455. Xfor i in 1 2 3 4 5 6 13 14 15 16 17 18
  1456. Xdo
  1457. Xecho $i
  1458. Xif test -f prob$i.ok
  1459. Xthen
  1460. Xcontinue
  1461. Xfi
  1462. Xif test -f prob$i.e
  1463. Xthen
  1464. X:
  1465. Xelse
  1466. Xbduflag=""
  1467. Xcase $i in
  1468. X    *17*) echo cc  ${bduflag} prob17.c -o prob17.e
  1469. X     cc  ${bduflag} prob17.c -o prob17.e -lm;;
  1470. X    *) echo cc prob$i.c -o prob$i.e
  1471. X     cc prob$i.c -o prob$i.e ;;
  1472. Xesac
  1473. Xfi
  1474. Xecho $i
  1475. Xprob$i.e<prob$i.in>prob$i.tst
  1476. Xif compare prob$i.ans prob$i.tst
  1477. Xthen
  1478. Xecho ok
  1479. Xcp /dev/null prob$i.ok
  1480. Xelse
  1481. Xecho bad
  1482. Xrm prob$i.e
  1483. Xfi
  1484. X
  1485. X
  1486. X
  1487. Xdiff prob$i.ans prob$i.tst
  1488. Xdone
  1489. X
  1490. END_OF_FILE
  1491. if test 487 -ne `wc -c <'testem'`; then
  1492.     echo shar: \"'testem'\" unpacked with wrong size!
  1493. fi
  1494. chmod +x 'testem'
  1495. # end of 'testem'
  1496. fi
  1497. if test -f 'visc' -a "${1}" != "-c" ; then 
  1498.   echo shar: Will not clobber existing file \"'visc'\"
  1499. else
  1500. echo shar: Extracting \"'visc'\" \(90 characters\)
  1501. sed "s/^X//" >'visc' <<'END_OF_FILE'
  1502. X#! /bin/sh
  1503. Xif test -f lock
  1504. Xthen
  1505. X    echo locked
  1506. X    exit
  1507. Xfi
  1508. Xtouch lock
  1509. Xvi ++ scoreboard
  1510. Xrm lock
  1511. END_OF_FILE
  1512. if test 90 -ne `wc -c <'visc'`; then
  1513.     echo shar: \"'visc'\" unpacked with wrong size!
  1514. fi
  1515. chmod +x 'visc'
  1516. # end of 'visc'
  1517. fi
  1518. echo shar: End of archive 1 \(of 3\).
  1519. cp /dev/null ark1isdone
  1520. MISSING=""
  1521. for I in 1 2 3 ; do
  1522.     if test ! -f ark${I}isdone ; then
  1523.     MISSING="${MISSING} ${I}"
  1524.     fi
  1525. done
  1526. if test "${MISSING}" = "" ; then
  1527.     echo You have unpacked all 3 archives.
  1528.     rm -f ark[1-9]isdone
  1529. else
  1530.     echo You still need to unpack the following archives:
  1531.     echo "        " ${MISSING}
  1532. fi
  1533. ##  End of shell archive.
  1534. exit 0
  1535.  
  1536.